package com.xiaotao.controller;

import com.xiaotao.dto.GoodDto;
import com.xiaotao.service.OrderService;
import com.xiaotao.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("order")
public class OrderController {
    @Resource
    private OrderService orderService;

    @PostMapping
    public Result addOrder(@RequestBody GoodDto goodDto) throws Exception {
        return orderService.addOrder(goodDto);
    }
    @GetMapping("{orderNum}")
    public Result findById(@PathVariable String orderNum){
        return orderService.findById(orderNum);
    }

    @GetMapping
    public Result list(){
        return orderService.findAll();
    }

    @PutMapping("{orderNum}")
    public Result update(@PathVariable String orderNum){
        return orderService.update(orderNum);
    }
}
